package com.bgs.travelapp.ticket.mapper;

import com.bgs.travelapp.mapper.BaseMapper;
import com.bgs.travelapp.ticket.entity.TicketEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface TicketMapper extends BaseMapper<TicketEntity> {

    /**
     * 购买门票时 门票数量 - 订单购买票数
     * lzy 2022-8-16 10点29分
     * @param id
     * @return
     */
    @Update("UPDATE ticket SET surplus_tickets = surplus_tickets-#{num},tickets_sold = tickets_sold+#{num} where scenic_id = #{id}")
    Integer UpdateTicketsde(@Param("id") Integer id, @Param("num") Integer num);

    /**
     * 购买门票未及时付款时 门票数量 + 订单购买票数
     * @param scenicId
     * @param ticketNum
     * @return
     */
    @Update("UPDATE ticket SET surplus_tickets = surplus_tickets + #{num},tickets_sold = tickets_sold - #{num} where scenic_id = #{id}")
    Integer UpdateTicketsin(@Param("id") Integer scenicId, @Param("num") Integer ticketNum);

}
